package com.zlst.uimp.cas;

import org.apereo.cas.configuration.model.core.authentication.PasswordEncoderProperties;
import org.apereo.cas.configuration.model.core.authentication.PrincipalTransformationProperties;
import org.apereo.cas.configuration.model.support.jpa.AbstractJpaProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by 170121 on 2018/6/8.
 */
@PropertySource("classpath:uimp.properties")
@ConfigurationProperties(value = "cas.uimp.authn.jdbc.encode")
public class CasUimpAuthenticationProperties extends AbstractJpaProperties{

    public CasUimpAuthenticationProperties() {
        System.out.println("====================初始化配置信息========================");
    }

    private String credentialCriteria;

    /**
     * Algorithm used for hashing.
     */
    private String algorithmName;
    /**
     * SQL query to execute and look up accounts.
     * Example: {@code SELECT * FROM table WHERE username=?}.
     */
//    @RequiredProperty
    private String sql = "SELECT * FROM sys_user WHERE username=?";

    /**
     * Password column name.
     */
    private String passwordFieldName = "password";
    /**
     * Field/column name that indicates the salt used for password hashing.
     */
//    @RequiredProperty
    private String saltFieldName = "salt";
    /**
     * Column name that indicates whether account is expired.
     */
    private String expiredFieldName;
    /**
     * Column name that indicates whether account is disabled.
     */
    private String disabledFieldName;

    /**
     * Field/column name that indicates the number of iterations used for password hashing.
     */
    private String numberOfIterationsFieldName = "numIterations";
    /**
     * Default number of iterations for hashing.
     */
    private long numberOfIterations;
    /**
     * Static salt to be used for hashing.
     */
    private String staticSalt;

    /**
     * Name of the authentication handler.
     */
    private String name;

    /**
     * Order of the authentication handler in the chain.
     */
    private int order = 10;

    /**
     * Principal transformation settings for this authentication.
     */
    @NestedConfigurationProperty
    private PrincipalTransformationProperties principalTransformation = new PrincipalTransformationProperties();

    /**
     * Password encoding strategies for this authentication.
     */
    @NestedConfigurationProperty
    private PasswordEncoderProperties passwordEncoder = new PasswordEncoderProperties();

    private List principalAttributeList = new ArrayList();

    public List getPrincipalAttributeList() {
        return principalAttributeList;
    }

    public void setPrincipalAttributeList(List principalAttributeList) {
        this.principalAttributeList = principalAttributeList;
    }

    public String getCredentialCriteria() {
        return credentialCriteria;
    }

    public void setCredentialCriteria(String credentialCriteria) {
        this.credentialCriteria = credentialCriteria;
    }

    public String getAlgorithmName() {
        return algorithmName;
    }

    public void setAlgorithmName(String algorithmName) {
        this.algorithmName = algorithmName;
    }

    public String getSql() {
        return sql;
    }

    public void setSql(String sql) {
        this.sql = sql;
    }

    public String getPasswordFieldName() {
        return passwordFieldName;
    }

    public void setPasswordFieldName(String passwordFieldName) {
        this.passwordFieldName = passwordFieldName;
    }

    public String getSaltFieldName() {
        return saltFieldName;
    }

    public void setSaltFieldName(String saltFieldName) {
        this.saltFieldName = saltFieldName;
    }

    public String getExpiredFieldName() {
        return expiredFieldName;
    }

    public void setExpiredFieldName(String expiredFieldName) {
        this.expiredFieldName = expiredFieldName;
    }

    public String getDisabledFieldName() {
        return disabledFieldName;
    }

    public void setDisabledFieldName(String disabledFieldName) {
        this.disabledFieldName = disabledFieldName;
    }

    public String getNumberOfIterationsFieldName() {
        return numberOfIterationsFieldName;
    }

    public void setNumberOfIterationsFieldName(String numberOfIterationsFieldName) {
        this.numberOfIterationsFieldName = numberOfIterationsFieldName;
    }

    public long getNumberOfIterations() {
        return numberOfIterations;
    }

    public void setNumberOfIterations(long numberOfIterations) {
        this.numberOfIterations = numberOfIterations;
    }

    public String getStaticSalt() {
        return staticSalt;
    }

    public void setStaticSalt(String staticSalt) {
        this.staticSalt = staticSalt;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getOrder() {
        return order;
    }

    public void setOrder(int order) {
        this.order = order;
    }

    public PrincipalTransformationProperties getPrincipalTransformation() {
        return principalTransformation;
    }

    public void setPrincipalTransformation(PrincipalTransformationProperties principalTransformation) {
        this.principalTransformation = principalTransformation;
    }

    public PasswordEncoderProperties getPasswordEncoder() {
        return passwordEncoder;
    }

    public void setPasswordEncoder(PasswordEncoderProperties passwordEncoder) {
        this.passwordEncoder = passwordEncoder;
    }
}
